#ifndef QCANVAS_H
#define QCANVAS_H
#include <QWidget>
#include <QMouseEvent>
#include <QPainter>
#include <QPixmap>
#include "Ptr.hpp"
#include "Document.h"
#include "ViewportControl.h"

using namespace OOPUtils;


class CanvasViewport : public QWidget
{

    Q_OBJECT

private:

  Ptr< Document > _pDoc;
  Ptr< ViewportControl > _pViewportControl;
  QPixmap _backgroundPattern;

  virtual void paintEvent (QPaintEvent * event);
  virtual void mouseMoveEvent (QMouseEvent * event);
  virtual void mousePressEvent (QMouseEvent * event);
  virtual void mouseReleaseEvent (QMouseEvent * event);
  virtual void resizeEvent (QResizeEvent * event);

public:

  CanvasViewport (Ptr< Document > pDoc, 
    Ptr< ViewportControl > pViewportControl);
  ~CanvasViewport ();

signals:

  void painting (QPainter & painter);
  void mouseMoved (QMouseEvent * event);
  void mousePressed (QMouseEvent * event);
  void mouseReleased (QMouseEvent * event);
  void resized (QSize newSize);

};

#endif // QCANVAS_H

